package com.dayu.web.controller.store;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.store.domain.AppletCompanyStore;
import com.dayu.store.service.IAppletCompanyStoreService;
import com.dayu.common.utils.poi.ExcelUtil;

/**
 * 公司门店Controller
 * 
 * @author HK
 * @date 2022-01-07
 */
@RestController
@RequestMapping("/store/companyStore")
public class AppletCompanyStoreController extends BaseController
{
    @Autowired
    private IAppletCompanyStoreService appletCompanyStoreService;

    /**
     * 查询公司门店列表
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:list')")
    @GetMapping("/list")
    public AjaxResult list(AppletCompanyStore appletCompanyStore)
    {
        List<AppletCompanyStore> list = appletCompanyStoreService.selectAppletCompanyStoreList(appletCompanyStore);
        return AjaxResult.success(list);
    }

    /**
     * 导出公司门店列表
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:export')")
    @Log(title = "公司门店", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppletCompanyStore appletCompanyStore)
    {
        List<AppletCompanyStore> list = appletCompanyStoreService.selectAppletCompanyStoreList(appletCompanyStore);
        ExcelUtil<AppletCompanyStore> util = new ExcelUtil<AppletCompanyStore>(AppletCompanyStore.class);
        return util.exportExcel(list, "companyStore");
    }

    /**
     * 获取公司门店详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appletCompanyStoreService.selectAppletCompanyStoreById(id));
    }

    /**
     * 新增公司门店
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:add')")
    @Log(title = "公司门店", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletCompanyStore appletCompanyStore)
    {
        return toAjax(appletCompanyStoreService.insertAppletCompanyStore(appletCompanyStore));
    }

    /**
     * 修改公司门店
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:edit')")
    @Log(title = "公司门店", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletCompanyStore appletCompanyStore)
    {
        return toAjax(appletCompanyStoreService.updateAppletCompanyStore(appletCompanyStore));
    }

    /**
     * 删除公司门店
     */
    @PreAuthorize("@ss.hasPermi('store:companyStore:remove')")
    @Log(title = "公司门店", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletCompanyStoreService.deleteAppletCompanyStoreByIds(ids));
    }
}
